/*
day54_2
2019.10.21
*/
#include<stdio.h>
#include<stdlib.h>


//struct TreeNode{
//	int val;
//	struct TreeNode *left;
//	struct TreeNode *right;
//};
//
//struct TreeNode* invertTree(struct TreeNode* root){
//	if(!root) return NULL;
//	struct TreeNode *temp;
//	temp=root->left;
//	root->left=root->right;
//	root->right=temp;
//	
//	if(root->left) invertTree(root->left);
//	if(root->right) invertTree(root->right);
//	
//	return root; 
//}


struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution {
public:
    TreeNode* invertTree(TreeNode* root) {
	    if(!root) return NULL;
		struct TreeNode *temp;
		temp=root->left;
		root->left=root->right;
		root->right=temp;
		
		if(root->left) invertTree(root->left);
		if(root->right) invertTree(root->right);
		
		return root; 
    }
    
};

int main()
{
	return 0;
}
